package control;

import javafx.application.Application;
import javafx.geometry.Side;
import javafx.scene.Scene;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TabPane.TabClosingPolicy;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;

// 标签面板组(非布局面板)
public class TabPaneDemo extends Application {
	private Pane root = new Pane();
	private TabPane tp;
	
	public static void main(String[] args) {
		launch(args);
	}
	
	@Override
	public void start(Stage stage) {
		
		tp = new TabPane();
		tp.setSide(Side.LEFT);		// 设置标签页放置位置
		tp.getSelectionModel().select(1);		// 设置默认打开的对应下标的标签页（从0开始）
//		tp.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);	 // 设置标签关闭法则(3种)
		tp.setPrefSize(300, 300);
		
		Tab t1 = new Tab("t1"); 
		t1.setGraphic(new Circle(8, Color.RED));
		Pane pane1 = new Pane();
		pane1.setStyle("-fx-background-color: red");
		t1.setContent(pane1);
		
		Tab t2 = new Tab("t2");
		t2.setClosable(false);		// 设置不可关闭
		Pane pane2 = new Pane();
		pane2.setStyle("-fx-background-color: yellow");
		t2.setContent(pane2);
		
		Tab t3 = new Tab("t3");
		Pane pane3 = new Pane();
		pane3.setStyle("-fx-background-color: green");
		t3.setContent(pane3);
		tp.getTabs().addAll(t1, t2, t3);
		root.getChildren().add(tp);
		
		Scene scene = new Scene(root, 400, 400);
		stage.setScene(scene);
		stage.show();
	}
}
